package models

// AppointmentTime 约棋时间段表
type AppointmentTime struct {
	BaseModel
	TimeSlot        string `gorm:"size:100;not null" json:"time_slot"`
	WeekDay         string `gorm:"size:20" json:"week_day"`
	StartTime       string `gorm:"size:20" json:"start_time"`
	EndTime         string `gorm:"size:20" json:"end_time"`
	Location        string `gorm:"size:255" json:"location"`
	MaxParticipants int    `gorm:"default:0" json:"max_participants"`
	CurrentCount    int    `gorm:"default:0" json:"current_count"`
	Description     string `gorm:"type:text" json:"description"`
	Sort            int    `gorm:"default:0" json:"sort"`
	Status          int    `gorm:"default:1;comment:状态 1启用 0禁用" json:"status"`
	IsRecommended   int    `gorm:"default:0;comment:是否推荐 1是 0否" json:"is_recommended"`
}

func (AppointmentTime) TableName() string {
	return "go_appointment_time"
}

// Appointment 约棋报名表
type Appointment struct {
	BaseModel
	UserID          uint   `gorm:"not null;index" json:"user_id"`
	TimeSlotID      uint   `gorm:"not null;index" json:"time_slot_id"`
	AppointmentDate string `gorm:"size:50" json:"appointment_date"`
	Opponent        string `gorm:"size:50" json:"opponent"`
	Notes           string `gorm:"type:text" json:"notes"`
	Status          string `gorm:"size:20;default:待确认" json:"status"`
	CheckInTime     string `gorm:"size:50" json:"check_in_time"`

	// 关联
	User            User            `gorm:"foreignKey:UserID" json:"user,omitempty"`
	AppointmentTime AppointmentTime `gorm:"foreignKey:TimeSlotID" json:"time_slot,omitempty"`
}

func (Appointment) TableName() string {
	return "go_appointment"
}
